<template>
	<view class="muen_box">
		<view class="title_tip">常用功能</view>
		<view class="muen_list">
			<view class="item" v-for="(item,index) in iconList" :key="index" @click="onClickPages(item.icon)">
				<image :src="`/static/network/home/icon${item.icon}.svg`" lazy-load mode="aspectFit" class="icon">
				</image>
				<view class="title">
					{{item.title}}
				</view>
			</view>
		</view>
	</view>
</template>

<script setup lang="ts">
	import {
		ref, onMounted, reactive
	} from "vue";
	import { onReachBottom, onPullDownRefresh, onUnload, onLaunch, onLoad, onShow } from '@dcloudio/uni-app'
	import apiNetwork from "@/util/network_api/network.js"
	import apiAccount from "@/util/network_api/account.js"
	import store from '@/store_network/index.js'
	const iconList = ref([{ title: '创建服务商', icon: 0 },
	{ title: '加入服务商', icon: 1 },
	// { title: '认证中心', icon: 2 },
	// { title: '邀请成员', icon: 3 },
	{ title: '工单报表', icon: 4 },
	{ title: '个人仓库', icon: 5 },
	{ title: '去结算', icon: 6 },
	{ title: '工单统计', icon: 7 },
	// { title: '知识库', icon: 8 },
	])
	const iconListAll = ref([{ title: '创建服务商', icon: 0 },
	{ title: '加入服务商', icon: 1 },
	// { title: '认证中心', icon: 2 },
	// { title: '邀请成员', icon: 3 },
	{ title: '工单报表', icon: 4 },
	{ title: '个人仓库', icon: 5 },
	{ title: '去结算', icon: 6 },
	{ title: '工单统计', icon: 7 },
	// { title: '知识库', icon: 8 },
	])
	onShow(async () => {
		if (!store.state.isManager) {
			iconList.value = iconListAll.value.filter(o => o.icon != 7)
		} else {
			iconList.value = iconListAll.value
		}
		apiAccount.getWithdrawRoot().then(res => {
			if (res.code == 20000) {
				if (!res.data.row) {
					iconList.value = iconList.value.filter(o => o.icon != 6)
				}
			}
		})
	})
	const onClickPages = (index) => {
		switch (index) {
			case 0:
				uni.navigateTo({
					url: '/pages/pages_network/user/create_network'
				})
				break;
			case 1:
				uni.navigateTo({
					url: '/pages/pages_network/user/add_network'
				})
				break;
			// case 2:

			// 	break;
			case 3:
				uni.navigateTo({
					url: '/pages/pages_network/home/addEmp'
				})
				break;
			case 4:
				uni.navigateTo({
					url: '/pages/pages_network/home/workOrder'
				})
				break;
			case 5:
				uni.navigateTo({
					url: '/pages/pages_network/home/oneStore'
				})
				break;
			case 6:
				// uni.showToast({
				// 	title: "正在维护中，敬请期待...",
				// 	duration: 800,
				// 	icon: "none"
				// })
				uni.navigateTo({
					url: '/pages/pages_network/home/myAccount/index'
				})
				break;
			case 7:

				uni.navigateTo({
					url: '/pages/pages_network/home/ordertotal'
				})
				break;
			// case 8:

			// 	break;
			default:
				uni.showToast({
					title: "正在维护中，敬请期待...",
					duration: 800,
					icon: "none"
				})
				break
		}
	}
</script>

<style lang="scss" scoped>
	.muen_box {
		margin: 32rpx;
		background-color: #fff;
		padding-bottom: 30rpx;
		border-radius: 16rpx;
		// box-shadow: 0 0 10rpx 1rpx #eee;
		border: 1rpx solid #eee;

		.title_tip {
			padding: 24rpx 0;
			margin: 0 30rpx;
			border-bottom: solid 1px #eee;
			font-size: 32rpx;
			font-weight: bold;
		}

		.muen_list {
			display: flex;
			flex-wrap: wrap;
			text-align: center;

			.item {
				width: 25%;
				margin-top: 32rpx;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;

				.title {
					margin-top: 12rpx;
					font-size: 28rpx;
				}

				.icon {
					font-size: 32rpx;
					width: 96rpx;
					height: 96rpx;
					border-radius: 50%;
				}
			}
		}
	}
</style>